-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cases] Use the new internal users API in the UI #150432
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userProfiles={userProfiles} | ||
/> | ||
{userActionsData?.participants ? ( | ||
{caseUsers?.reporter ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we show the Unknown
user if we don't have the reporter instead of hiding the list?
I suppose another option would be to fallback to the case data right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I will fallback to the case data.
@@ -957,3 +958,85 @@ export const getPersistableStateAttachment = ( | |||
...viewObject, | |||
}), | |||
}); | |||
|
|||
export const getCaseUsersMockResponse = (): CaseUsers => { | |||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a mock response that only has the profileUid
?
...users.assignees, | ||
...users.participants, | ||
users.reporter, | ||
...users.unassignedUsers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have uniq
users array like it was before in
const uidsToRetrieve = uniq([...userActionProfileUids, ...assignees]);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Map
below guarantees that only unique profiles will be added. The map will contain all valid user profiles.
}, | ||
}, | ||
], | ||
unassignedUsers: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a stupid question 😄
What is the difference between unassignedUsers
and Participants
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no stupid questions 🙂! Participants are all users that did an action in the case. For example, edit a description, a comment, etc. Now, if you assign a user to a case a user action will be created containing the uid of the user. Same if you remove an assignee (unassigned user). We need the profile information for that users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, got it. Thanks 🙂
@@ -80,137 +74,4 @@ describe('UseFindCaseUserActions', () => { | |||
expect(spy).toHaveBeenCalledWith(basicCase.id, expect.any(AbortSignal)); | |||
expect(addError).toHaveBeenCalled(); | |||
}); | |||
|
|||
describe('getProfileUids', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!! 🎉 🙌
I also see the same behaviour. Showing |
f15e24e
to
d8e94d8
Compare
Damn, Rigid Rodent did it again. Thanks, both of you for finding the bug. I should be more careful. I pushed the fix and added many unit tests to check user profile variations. The bug occurred because I converted the response to camel case when the UI expected it to be in snake case. That was the format returned by the
No, but it should. I fixed it in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified locally, looks great 👍 🎉
}), | ||
rt.partial({ uid: rt.string }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way we can tie this implementation with the security plugin 🤔 My concern is that if they make a breaking change to the response structure and make the changes throughout the code base, this won't show up as needing to be changed and it will break the UI.
Here's an idea, how about we add an integration test that does a bulk get using the security API and then does a decode using this schema? Or something like that, that way if there's a breaking change at least we'll get a failing test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing idea! I was thinking about the same but I could not find a good way to do it.
{caseUsers?.participants ? ( | ||
<UserList | ||
dataTestSubj="case-view-user-list-participants" | ||
theCase={caseData} | ||
headline={i18n.PARTICIPANTS} | ||
loading={isLoadingUserActions} | ||
users={caseUsers.participants} | ||
users={[...caseUsers.participants, ...caseUsers.assignees]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the ternary operator on line 245 need to be updated to reflect the assignees
too?
How about we combine the array above this component and just check to see if it's not empty? Although is it even possible to have assignees but not a participant 🤔 that'd mean we don't have the reporter's information I suppose. Either probably best to check just in case the backend has a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
...st/cases_api_integration/security_and_spaces/tests/common/internal/user_actions_get_users.ts
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @cnasikas |
Summary
This PR updates the UI to use the new
users
API introduced in #149663. I changed the backend response to accommodate the needs of the UI.Checklist
Delete any items that are not applicable to this PR.
For maintainers